import React from 'react';
import { getToken } from 'utils/storage';
import { Route } from 'react-router-dom';

export default function AuthRoute(props) {
  const { path, component: Comp } = props;
  return (
    <Route
      path={path}
      render={(props) => {
        // console.log(props);
        if (!!getToken()) {
          return <Comp {...props} />;
        }

        props.history.push('./login');
      }}
    ></Route>
  );
}
